package com.sia.springcloud.process;

import com.sia.springcloud.process.consumer.KafkaConsumerAbb;
import com.sia.springcloud.process.consumer.KafkaConsumerBosh;
import com.sia.springcloud.process.consumer.KafkaConsumerS7;
import com.sia.springcloud.process.consumer.TestConsumer;
import com.sia.springcloud.process.influxDB.InfluxDbTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * @Author: Sirius
 * @Date: 2022/5/14 17:42
 * @Description:
 **/
@Component
public class AutoRunner implements ApplicationRunner {

    @Autowired
    private InfluxDbTool influxDbTool;


    public void run(ApplicationArguments args) throws Exception {


        /**
         * abb
         */
        KafkaConsumerAbb abb = new KafkaConsumerAbb("abb", influxDbTool);
        Thread thread1 = new Thread(abb);
        thread1.start();

        /**
         * bosh
         */
        KafkaConsumerBosh bosh = new KafkaConsumerBosh("bosh", influxDbTool);
        Thread thread2 = new Thread(bosh);
        thread2.start();

        /**
         * s7
         */
        KafkaConsumerS7 s7 = new KafkaConsumerS7("s7", influxDbTool);
        Thread thread3 = new Thread(s7);
        thread3.start();


        TestConsumer testConsumer = new TestConsumer("modbus",influxDbTool);
        Thread thread4 = new Thread(testConsumer);
        thread4.start();


    }
}

